import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author gao
 * @date 2025/6/21 13:31
 */

public class Solution {
    public int[] twoSum(int[] nums, int target) {
        // 用于存储数组中的元素及其对应的索引
        Map<Integer, Integer> hash = new HashMap<>();

        for (int i = 0; i < nums.length; i++) {
            int x = target - nums[i];
            // 如果HashMap中包含该差值，则返回该差值的索引和当前元素的索引
            if (hash.containsKey(x)) {
                return new int[]{i, hash.get(x)};
            }
            // 将当前元素及其索引存入HashMap中
            hash.put(nums[i], i);
        }

        return new int[]{-1, -1};
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = scanner.nextInt();
            }
            int target = scanner.nextInt();
            Solution solution = new Solution();
            System.out.println(Arrays.toString(solution.twoSum(nums, target)));
        }
    }
}
